<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>index.js</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="../../../../../../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../../../../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../../../../css/github.css" type="text/css" media="screen" />
<script src="../../../../../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../../../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../../../../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../../../../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>
    <div class="banner">
        
        <h1>
            index.js
        </h1>
        <ul class="files">
            
            <li>
                lib/assets/javascripts/ems_app/store_staff_salaries/index.js
                
            </li>
            <li>Last modified: 2017-02-24 15:07:24 +0800</li>
        </ul>
    </div>

    <div id="bodyContent">
        <div id="content">
  
    <div class="description">
      
<p>jQuery(function($){</p>

<pre><code>// 点击显示审核框子
  $(&quot;a.js-to-check-this-salary&quot;).on(&quot;click&quot;, function(e){
    var checkSalaryTemp = JST[&quot;ems/store_staff_salaries/check_salary&quot;]
    e.preventDefault();
    var staffId = $(this).parents(&quot;tr.js-salary-item-tr&quot;).data(&quot;id&quot;);
    $.ajax({
      url: &quot;/api/store_staffs/&quot;+staffId,
      success: function(data){
        if(data.status){
          $(&quot;div.js-show-check-salary-area&quot;).html(checkSalaryTemp(data))
        }else {
          showErrorView(&quot;服务器出错!&quot;);
        }
      }
    })
  });

  //点击保存更新内容，目前已经移除
  $(document).on(&quot;click&quot;, &quot;input.js-to-update-salary&quot;, function(e){
    e.preventDefault();
    var id = $(this).parents(&quot;form#update_salary&quot;).data(&quot;id&quot;);
    var formData = $(this).closest(&quot;form#update_salary&quot;).serializeJSON();
    // var csrf = $(&quot;input#js-ems-store-salaries-update&quot;).val();
    formData.store_staff_salary.status = false
    updateSalary(formData, id)
  });

  //js-to-check-salary 点击审核去改变状态为已经审核
  $(document).on(&quot;click&quot;, &quot;input.js-to-check-salary&quot;, function(e){
    e.preventDefault();
    var id = $(this).parents(&quot;form#update_salary&quot;).data(&quot;id&quot;);
    var formData = $(this).closest(&quot;form#update_salary&quot;).serializeJSON();
    // var csrf = $(&quot;input#js-ems-store-salaries-update&quot;).val();
    formData.store_staff_salary.status = true
    updateSalary(formData, id)
  })

  // 这个是ajax请求
  function updateSalary(data, id){
    var csrf = $(&quot;input#js-ems-store-salaries-update&quot;).val();
    $.ajax({
      url: &quot;/api/store_staff_salaries/&quot;+id,
      method: &quot;put&quot;,
      data: data,
      headers:{
        &#39;X-CSRF-Token&#39;: csrf
      },
      success: function(data){
        if(data.status){
          $(&quot;div.js-show-check-salary-area&quot;).html(&quot;&quot;);
          location.href = &quot;/ems/store_staff_salaries&quot;
        }else {
          showErrorView(&quot;保存失败，服务器出错！&quot;)
        }
      }
    })
  };</code></pre>

<p>})</p>

    </div>
  


  


  
  


  


  

  



  

    

    

    


    


    <!-- Methods -->
              </div>

    </div>
  </body>
</html>
